package control.mock_db;

import java.util.ArrayList;
import java.util.List;

import domain.Review;

public class ReviewDaoMock {
	List<Review> container;

	public ReviewDaoMock() {
		container =  new ArrayList<Review>();
		Review review1 = new Review();
		review1.setRating(5);
		review1.setReview("gut gut");
		container.add(review1);
	}

	public List<Review> getAll(){
		return container;
	}
	
	public void save(Review review){
		Review existing = null;
		for (Review r : container) {
			if (r.getId() == review.getId()) {
				existing = r;
				break;
			}
			container.remove(existing);
			container.add(review);
		}
		container.add(review);
	}
	
	public void remove(Review review) {
		container.remove(review);
	}

}
